#ifndef LINK_DEFS

#define LINK_DEFS

#include "globals.h"

#define LEFT	1
#define RIGHT	2
#define UP		LEFT
#define DOWN	RIGHT

/*	Define the structure of a heap -- an item count, a key
    list, and a set of pointers for data. */

#define EQUAL		'='
#define LEFT_HEAVY	'/'
#define RIGHT_HEAVY '\\'

typedef struct _link_node {
	long				name;
	boolean				head, tail;
	struct _link_node	*prev, *next;
	struct _link_node	*left, *right, *parent;
	char				balance;
	void				*data;
	} link_node;

typedef struct _link_ref {
	link_node	*head;
	link_node	*middle;
	int			count;
	}	link_ref;

#ifdef __cplusplus
extern "C" {
#endif

link_ref *initLink(void);
boolean	addAfterLink (link_ref *link, link_node *node, void *data,
	link_node **newNode);
boolean	addBeforeLink (link_ref *link, link_node *node, void *data,
	link_node **newNode);
boolean	deleteLink (link_ref *link, link_node **node, void **data);
void	killLink (link_ref **link);
void	printLink (link_ref *link);
short	sizeOfLinkList(link_ref *link);
link_node	*nextLink (link_ref *link, link_node *node);
link_node	*prevLink (link_ref *link, link_node *node);
boolean getLinkInfo (link_node *node, void **data);

link_node	*binSearchLink (link_ref *link, link_node *current, int side);

#ifdef __cplusplus
}
#endif

#endif
